#include <vector>
#include <set>
#include <iostream>
#include <unordered_map>
#include <numeric>

using namespace std;

vector<vector<int>> generateMatrix(int n) {
    vector<vector<int>> matrix(n, vector<int>(n, 0));
    int i = 0, j = 0, z = 1;
    while(z <= n*n){
        while(i >= 0 && i < matrix.size() && j >= 0 && j < matrix[0].size() && matrix[i][j] == 0 ){
            matrix[i][j++] = z++;
        }
        i++; j--;
        while(i >= 0 && i < matrix.size() && j >= 0 && j < matrix[0].size() && matrix[i][j] == 0 ){
            matrix[i++][j] = z++;
        }
        i--; j--;
        while(i >= 0 && i < matrix.size() && j >= 0 && j < matrix[0].size() && matrix[i][j] == 0 ){
            matrix[i][j--] = z++;
        }
        i--; j++;
        while(i >= 0 && i < matrix.size() && j >= 0 && j < matrix[0].size() && matrix[i][j] == 0 ){
            matrix[i--][j] = z++;
        }
        i++; j++;
    }
    return matrix;
}

int main(){
    vector<vector<int>> ret = generateMatrix(6);
    for(int i = 0; i < ret.size(); i++){
        cout << ret[i][0] << endl;
    }
    return 0;
}